package org.dfl.plugin.editor.model;

import java.util.List;
import java.util.Map;

import org.dfl.core.data.types.TypeManager;
import org.dfl.core.model.TInputEdge;
import org.dfl.core.model.TOutputEdge;
import org.dfl.core.model.XMLLoaderException;
import org.jdom.Element;

/**
 * editor's model element that represents a nested connection edge
 * @author Piotr Wlodarczyk
 *
 */
public class NestedConnectionModelElement extends ConnectionModelElement {

	public NestedConnectionModelElement(Element elem, Map<String, Shape> modelMap) throws XMLLoaderException {
		super(elem, modelMap);
	}

	public NestedConnectionModelElement(Shape source, Shape target) {
		super(source, target);
	}
	
	@Override
	protected List<String> getFreeInputs(PlaceModelElement p, TransitionModelElement t) {
		return t.getTransition().getFreeInputs(TypeManager.getCollectionType(p.getPlace().getTypeContainer().getType()));
	}
	
	@Override
	protected TInputEdge getNewTInputEdge() {
		TInputEdge e = super.getNewTInputEdge();
		e.setNested(true);
		return e;
	}
	
	@Override
	protected TOutputEdge getNewTOutputEdge() {
		TOutputEdge e = super.getNewTOutputEdge();
		e.setNested(true);
		return e;
	}
}
